package com.app.mvvmkotlindemo.request

import androidx.lifecycle.MutableLiveData
import com.app.mvvmkotlindemo.bean.ImgVerifyBean
import com.app.mvvmkotlindemo.bean.JwtTokenBean
import com.app.mvvmkotlindemo.bean.UserBean
import com.everyline.baselibrary.base.viewmodel.BaseViewModel
import com.everyline.baselibrary.ext.request
import com.everyline.baselibrary.state.ResultState

import com.app.mvvmkotlindemo.network.HttpRequestManger


/**
 * Created by on 2020/12/1.
 * 天天挂线
 *  746608431@qq.com
 *  描述:TODO
 */

class RequestLoginCodeModel : BaseViewModel() {

    var codeData = MutableLiveData<ResultState<String?>>()

    var userBeanData = MutableLiveData<ResultState<UserBean?>>()
    var userBeanTokenData = MutableLiveData<ResultState<UserBean?>>()
    var imgVerifyData = MutableLiveData<ResultState<ImgVerifyBean?>>()
    var driverRegisteData = MutableLiveData<ResultState<JwtTokenBean?>>()


    fun sendSmsCode(map: Map<String, String>) {

        request({ HttpRequestManger.apiService.sendSmsCode(map) }, codeData, false)

    }

    fun driverLoginByMobile(map: Map<String, String>) {
        request({ HttpRequestManger.apiService.driverLoginByMobile(map) }, userBeanData, true)

    }

    fun driverLoginByToken(map: Map<String, String>) {
        request({ HttpRequestManger.apiService.driverLoginByToken(map) }, userBeanTokenData, false)

    }

    fun getImgVerify(map: Map<String, String>) {
        request({ HttpRequestManger.apiService.getImgVerify(map) }, imgVerifyData, true)
    }


    fun driverRegister(validStr: String, map: Map<String, String>) {
        request(
            { HttpRequestManger.apiService.driverRegister(validStr, map) },
            driverRegisteData,
            true
        )

    }


}